{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2\n",
    "import os \n",
    "import random\n",
    "import torch\n",
    "from torchvision import transforms"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "stable_prefix = 'E:/Datasets/DeepStab Modded/Stable_60/'\n",
    "unstable_prefix = 'E:/Datasets/DeepStab Modded/Unstable/'\n",
    "flow_prefix = 'E:/Datasets/DeepStab Modded/Flows_256x256'\n",
    "feature_prefix = 'E:/Datasets/DeepStab Modded/matched_features'\n",
    "videos = os.listdir(feature_prefix)\n",
    "with open('./trainlist.txt','w') as f:\n",
    "    for vid in videos:\n",
    "        video_name = vid.split('.')[0] + '.avi'\n",
    "        s_path = os.path.join(stable_prefix, video_name)\n",
    "        u_path = os.path.join(unstable_prefix, video_name)\n",
    "        flow_path = os.path.join(flow_prefix,vid)\n",
    "        feature_path = os.path.join(feature_prefix,vid)\n",
    "        s_cap = cv2.VideoCapture(s_path)\n",
    "        u_cap = cv2.VideoCapture(u_path)\n",
    "        num_frames = min(int(s_cap.get(cv2.CAP_PROP_FRAME_COUNT)),int(u_cap.get(cv2.CAP_PROP_FRAME_COUNT)))\n",
    "        for idx  in range(33,num_frames):\n",
    "            line = f'{s_path},{u_path},{flow_path},{feature_path},{idx}\\n'\n",
    "            f.write(line)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "DUTCode",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
